{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0 1 2]\n",
      " [3 4 5]]\n",
      "\n",
      "\n",
      "[[0 3]\n",
      " [1 4]\n",
      " [2 5]]\n",
      "\n",
      "\n",
      "0, 1, 2, 3, 4, 5, \n",
      "\n",
      "0, 3, 1, 4, 2, 5, \n",
      "\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    " \n",
    "a = np.arange(6).reshape(2,3)\n",
    "print (a)\n",
    "print ('\\n')\n",
    "b = a.T\n",
    "print (b)\n",
    "print ('\\n')\n",
    "for x in np.nditer(b):\n",
    "    print (x, end=\", \" )\n",
    "print ('\\n')\n",
    " \n",
    "for x in np.nditer(b,order='C'):\n",
    "    print (x, end=\", \" )\n",
    "print ('\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0 1 2]  一行:\n",
      "[3 4 5]  一行:\n",
      "[6 7 8]  一行:\n",
      "\n",
      "\n",
      "迭代后的数组：\n",
      "0,1,2,3,4,5,6,7,8,"
     ]
    }
   ],
   "source": [
    "a = np.arange(9).reshape(3,3) \n",
    "for row in a:\n",
    "    print(row, end='  一行:\\n')\n",
    "print ('\\n') \n",
    "#对数组中每个元素都进行处理，可以使用flat属性，该属性是一个数组元素迭代器：\n",
    "print ('迭代后的数组：')\n",
    "for element in a.flat:\n",
    "    print(element,end=',')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "第一个数组：\n",
      "[[1 2 3 4]]\n",
      "\n",
      "\n",
      "第二个数组：\n",
      "[[5 6 7 8]]\n",
      "\n",
      "\n",
      "沿轴 0 连接两个数组：\n",
      "[[1 2 3 4]\n",
      " [5 6 7 8]]\n",
      "\n",
      "\n",
      "沿轴 1 连接两个数组：\n",
      "[[1 2 3 4 5 6 7 8]]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import numpy as np\n",
    " \n",
    "a = np.array([ [1,2,3,4] ])\n",
    " \n",
    "print ('第一个数组：')\n",
    "print (a)\n",
    "print ('\\n')\n",
    "b = np.array([ [5,6,7,8] ])\n",
    " \n",
    "print ('第二个数组：')\n",
    "print (b)\n",
    "print ('\\n')\n",
    "# 两个数组的维度相同\n",
    " \n",
    "print ('沿轴 0 连接两个数组：')\n",
    "print (np.concatenate((a,b)))\n",
    "print ('\\n')\n",
    " \n",
    "print ('沿轴 1 连接两个数组：')\n",
    "print (np.concatenate((a,b),axis = 1))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3]\n",
      " [ 4  5  6  7]\n",
      " [ 8  9 10 11]]\n",
      "\n",
      "\n",
      "[[ 0  1  2  3]\n",
      " [ 8  9 10 11]]\n",
      "\n",
      "\n",
      "[[ 0  2  3]\n",
      " [ 4  6  7]\n",
      " [ 8 10 11]]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "import numpy as np\n",
    " \n",
    "a = np.arange(12).reshape(3,4)\n",
    " \n",
    "print (a)\n",
    "print ('\\n')\n",
    " \n",
    "print (np.delete(a,1,axis = 0))\n",
    "print ('\\n')\n",
    "\n",
    "print (np.delete(a,1,axis = 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
